﻿//Author:Christian TQ
using System;
using System.Text;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;

namespace TQ.Sharepoint.Webparts.ListQuickSearch
{
    public partial class ListQuickSearchUserControl : UserControl
    {
        private string _listName;
        private string _fieldName;
        private int _numItems;

        public string listName { get { return _listName; } set { _listName = value; } }
        public string fieldName { get { return _fieldName; } set { _fieldName = value; } }
        public int numItems { get { return _numItems; } set { _numItems = value; } }
        

        protected void Page_Load(object sender, EventArgs e)
        {

            StringBuilder script = new StringBuilder();
            script.Append("<script type=\"text/javascript\">");
            script.Append("var config = {");
            script.Append("listTitle: '" + listName + "',");
            script.Append("fieldName: '" + fieldName + "',");
            script.Append("delay: 500,");
            script.Append("minCharacters: 3,");
            script.Append("pageItems: " + _numItems + ",");
            script.Append("resultsAnimation: 100,");
            script.Append("resultAnimation: 0");
            script.Append("};");
            script.AppendLine("var quickSearchTimer;");
            script.AppendLine("var quickSearchSelectedDivIndex = -1;");
            script.AppendLine("var listCollection;");
            script.AppendLine("var listId = null;  ");
            script.Append("</script>");
            listQuickSearchConfig.Text = script.ToString();

        }
    }
}
